<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>发货仓管理</title>
</head>
<body>
    <div ng-app="myApp" ng-controller="WarehouseCtrl">
        <div class="row">
            <ui-container url="system/warehouse/list" key="warehouse-list-00">
                <ui-search-form>
                    <search-input class="col-md-3" name="warehouseCode" placeholder="请输入发货仓编码"></search-input>
                    <search-input class="col-md-3" name="warehouseName" placeholder="请输入发货仓名称"></search-input>
                    <search-select class="col-md-3" name="state">
                        <option value="">请选择激活状态</option>
                        <option value="0">非激活 </option>
                        <option value="1">激活</option>
                    </search-select>
                </ui-search-form>
                <ui-table-tool>
                    <a class="btn btn-sm btn-primary" href="system/warehouse/add" >新增</a>
                    <a class="btn btn-sm btn-primary" href="javascript:void(0);" onclick="reSet()">重置</a>
                </ui-table-tool>
                <ui-table>
                    <ui-form-input name="warehouseCode" label="发货仓编码:" ></ui-form-input>
                    <ui-form-input name="warehouseName" label="发货仓名称:"></ui-form-input>
                    <ui-form-input name="state" label="激活状态:" ></ui-form-input>
                    </ui-form>
                    <ui-form-input name="provinceName" label="发货省份:"></ui-form-input>
                    <ui-form-input name="cityName" label="发货城市:"></ui-form-input>
                    <ui-form-input name="countyName" label="发货区县:"></ui-form-input>
                </ui-table>
                <table-page/>
            </ui-container>
        </div>
        <div class="row" id="supplierImport">
            <a  class="btn btn-sm btn-primary" href="javascript:void(0);" ng-click="exportDatas()" target="_blank" >下载模板</a>
            <ui-upload url="system/warehouse/import" success="uploadSuccess"></ui-upload>
        </div>
    </div>
<script>
    angular.module('myApp',['ui.table']);
    angular.module('myApp').controller('WarehouseCtrl', function($scope){
        $scope.uploadSuccess=function (returndata) {
            $("#warehouseImport").find(".upload-result").remove();
            if(returndata.data["fileKey"]){
                $("#warehouseImport").append('<a  class="btn btn-sm btn-success upload-result" href="system/supplier/down?fileKey='+returndata.data["fileKey"]+'" target="_blank" >下载导入失败的记录</a>');
            }
            toastr.success("总共"+returndata.data["totalNums"]+"条,成功"+returndata.data["successNums"]+"条");
        }

        $scope.exportDatas = function(){
            var params = {
                url: 'system/warehouse/exporttemplate',
                type: "POST"
            };
            var exportForm = $("<form>");
            $(exportForm).css("display", "none");
            $(exportForm).attr('target', 'targetFrame');
            $(exportForm).attr('method', params.type);
            $(exportForm).attr('action', params.url);
            exportForm = exportForm.appendTo($("body"));
            exportForm.submit();
            exportForm.remove();
        }

        function doDel(selectedItems) {
            const uiContainerCtrl=$scope['warehouse-list-00'];
            if(!selectedItems||selectedItems.length<=0){
                toastr.error("没有选中删除对象")
                return;
            }
            var ids=selectedItems.map(m => m.id);
            $.ajax({
                url:'system/warehouse/delete',
                data:{ids:ids.join(",")}
            }).done(function (result) {
                if(result.code == '0000'){
                    toastr.success(result.data);
                    uiContainerCtrl._queryData({});
                }else{
                    toastr.error(result.msg);
                }

            }).fail(function (r) {
                toastr.error("服务器异常"+r);

            });

        }

        $scope.addOrg=function (items) {
            console.info(items)
        }
        //每一列的操作按钮
        $scope._operateColumns=[{text:'编辑',click:function (data) {
            window.open("system/warehouse/update?id="+data.id,"_target");
        }}]

        $scope._columns=[   {name:'id',head:'id'},
            {name:'warehouseCode',head:'发货仓编码'},
            {name:'warehouseName',head:'发货仓名称'},
            {name:'state',head:'激活状态',render(data,value){return value=='0'?'否':'是'}},
            {name:'provinceName',head:'发货省份'},
            {name:'cityName',head:'发货城市'},
            {name:'countyName',head:'发货区县'}
        ];
    });
</script>
<script src="static/common/js/common.js"></script>
</body>
</html>


